package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.DeptFile;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DeptFileUserStore;
import com.ruoyi.system.service.IDeptFileUserStoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 文件收藏Controller
 *
 * @author ruoyi
 * @date 2024-04-17
 */
@RestController
@RequestMapping("/system/store")
public class DeptFileUserStoreController extends BaseController
{
    @Autowired
    private IDeptFileUserStoreService deptFileUserStoreService;

    /**
     * 查询文件收藏列表
     */
    @PreAuthorize("@ss.hasPermi('system:store:list')")
    @PostMapping("/list")
    public AjaxResult list(@RequestBody DeptFile deptFile)
    {
        List<DeptFile> list = deptFileUserStoreService.selectDeptFileUserStoreList(deptFile);
        return success(list);
    }


    /**
     * 取消收藏
     */
    @PreAuthorize("@ss.hasPermi('system:file:remove')")
    @Log(title = "部门文件", businessType = BusinessType.DELETE)
    @DeleteMapping("/storeFile/{fileId}")
    public AjaxResult cancelStoreFile(@PathVariable Long fileId)
    {
        return toAjax(deptFileUserStoreService.cancelStoreFile(fileId));
    }


}
